﻿
Partial Class App_PostSearch
    Inherits MyUI.PageBaseApp

    Protected CurrAccount As mDB.Account
    Protected tc As WebApi.Twitter.TwitterClient
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load


        CurrAccount = CurrUser.CurrAccount


        tc = New WebApi.Twitter.TwitterClient(CurrAccount.getOauth)

        If Not Me.IsPostBack Then
            SetDataPage()
        End If

    End Sub

    Private Sub SetDataPage()

        'SetListAccount()

        If CurrAccount IsNot Nothing Then


            SetListMessage()


        End If

        'Me.UpPConversations.Update()

    End Sub


    Protected Sub SetListMessage()

        Me.LblSearch.Text = UI.Page.GetValue("q")

        Dim posts = tc.GetSearch(UI.Page.GetValue("q"), "", "")

        Dim Data = (From Post In posts.statuses Select Post, User = Post.user, Post.id_str).ToList

        'Data(0).Post .created_at 

        Dim DataBind As List(Of Object) = UI.ListData.Bind(Me.ListMessage, Data, {"id_str"})

        If DataBind.Count > 0 Then
            MyUI.Data.SetListStatusPost(CurrAccount, UI.ListData.GetRowsList(Me.ListMessage), DataBind.Select(Function(o) o.Post.id_str.ToString).ToList)
            MyUI.Data.SetListStatusAccount(CurrAccount, UI.ListData.GetRowsList(Me.ListMessage), DataBind.Select(Function(o) o.User.id_str.ToString).ToList)

        End If


    End Sub

End Class
